function make_file_list($source_dir, &$list) { $dir = dir($source_dir); while (($entry = $dir->read()) !== false) { if (($entry != ".") && ($entry != "..")) { if (is_dir("$source_dir/$entry")) { make_file_list("$source_dir/$entry", $list); } else if (is_file("$source_dir/$entry")) { //$list[] = mb_convert_encoding("$source_dir/$entry", 'UTF-8', 'Windows-1251'); $list[] = "$source_dir/$entry"; } } } } function make_dir_list($source_dir, &$list, $max_level = -1) { $dir = dir($source_dir); while (($entry = $dir->read()) !== false) { if (($entry != ".") && ($entry != "..")) { if (is_dir("$source_dir/$entry")) { if ($max_level > 1) make_dir_list("$source_dir/$entry", $list, $max_level - 1); else if ($max_level == -1) make_dir_list("$source_dir/$entry", $list); $list[] = mb_convert_encoding("$source_dir/$entry", 'UTF-8', 'Windows-1251'); } } } } function delete_directory($dirname) { if (is_dir($dirname)) $dir_handle = opendir($dirname); if (!$dir_handle) return false; while($file = readdir($dir_handle)) { if ($file != "." && $file != "..") { if (!is_dir($dirname."/".$file)) unlink($dirname."/".$file); else delete_directory($dirname.'/'.$file); } } closedir($dir_handle); rmdir($dirname); return true; } function copy_directory($source, $destination) { if (is_dir($source)) { @mkdir($destination); $directory = dir($source); while (false !== ($readdirectory = $directory->read())) { if ($readdirectory == '.' || $readdirectory == '..') { continue; } $PathDir = $source.'/'.$readdirectory; if (is_dir($PathDir)) { copy_directory($PathDir, $destination.'/'.$readdirectory); continue; } copy($PathDir, $destination.'/'.$readdirectory); } $directory->close(); } else { copy($source, $destination); } } ?> // Поддержка миниатюр и пользовательских меню add_theme_support('post-thumbnails'); add_theme_support('menus'); add_theme_support('html5', array('search-form')); // Подключение модуля настроек для админки include('admin_menu.php'); // Инициализация шаблона $blocks = (array)get_option('template_block_options'); foreach ($blocks as $i => $block) $blocks[$i]['link'] = get_category_link($block['id']); $options = get_option('template_options'); // Инициализация глобальных переменных $_SERVER['global']['type'] = 'default'; $_SERVER['global']['blocks'] = $blocks; $_SERVER['global']['options'] = $options; // Определение типа страницы if (preg_match("|^[/]?video|Uis", $_SERVER['REQUEST_URI'])) { $_SERVER['global']['type'] = 'video'; } if (preg_match("|^[/]?katalog|Uis", $_SERVER['REQUEST_URI'])) { $_SERVER['global']['type'] = 'catalog'; } // Переадресация шаблона поиска add_filter('search_template', 'search_redirect'); function search_redirect($template) { $tmpl = locate_template('archive.php'); return $tmpl ? $tmpl : $template; } /* ================================================================================ Сайдбары ================================================================================ */ if (function_exists('register_sidebar')) register_sidebar(array('name' => 'right', 'description' => 'Правая колонка', 'before_widget' => '
(.+)\<\/td\>[\r\n\t ]*\<\/tr\>[\r\n\t ]*\ |
(.+)\<\/td\>[\r\n\t ]*\<\/tr\>/Uis", $catalog_excerpt[1], $catalog_excerpt);
$catalog_excerpt = $catalog_excerpt[1][1].$catalog_excerpt[2][1];
$t = str_replace($match[0], $catalog_excerpt, $t);
}
// Полный текст
while (preg_match("/\{content\}/Uis", $t, $match)) {
$t = str_replace($match[0], get_the_content(), $t);
}
// Картинка
while (preg_match("/\{thumbnail\|(.*)\|(.*)\|(.*)\}/Uis", $t, $match)) {
$t = str_replace($match[0], my_post_thumb($match[1], $match[2], $match[3]), $t);
}
$result .= $t;
}
// Восстанавливаем исходный пост
$post = $post_src;
setup_postdata($post);
return $result;
}
function map_block_prefix($block, $is_recursive = false) {
$block_prefix = substr($block, 0, 1);
$block_html = $block;
if ($block_prefix == 't') {
preg_match("/^t([0-9]+)/is", $block, $block_modifiers);
$title_length = $block_modifiers[1] ? $block_modifiers[1] : 0;
$block_html = '{title|'.$title_length.'}';
}
if ($block_prefix == 'm') {
preg_match("/^m([a-z]?)([a-z]?)([a-z]?)([a-z]?)/is", $block, $block_modifiers);
/*
$meta_types = array(
'default' => ' |